#include <stdio.h>

int main(){
	int a[] = {4,5,2,4,7,6,3,3,2,5};

	int N = 10;
	int i = 0;
	int j = 0;
	printf("a[]=");
	for (i = 0; i < N; i++){
		printf("%d ",a[i]);
	}
	printf("\n");

	int tmp = 0;
	for (i = 1; i < N; i++){
		tmp = a[i];
		for (j = i - 1; j >= 0; j--){
			if(tmp < a[j]){
				a[j+1] = a[j];
			}else{break;}
		}
		a[j+1] = tmp;
	}

	printf("插入排序后：\n");
	printf("a[]=");
	for (i = 0; i < N; i++){
		printf("%d ",a[i]);
	}
	printf("\n");

	for (i = 0; i < N; i++){
		if(a[i] == a[i+1]){
			for (j = i; j < N; j++){
				a[j] = a[j+1];
			}
			a[N-1] = 0;
		}
	}	

	printf("去重后：\n");
	printf("a[]=");
	for (i = 0; i < N; i++){
		printf("%d ",a[i]);
	}
	printf("\n");

	return 0;
}
